package com.qianfeng.biz.impl;

import java.util.List;

import com.qianfeng.biz.IGoodsInfoBiz;
import com.qianfeng.dao.IGoodsInfoDao;
import com.qianfeng.dao.impl.GoodsInfoDaoImpl;
import com.qianfeng.dto.PageBean;
import com.qianfeng.entity.GoodInfo;
import com.qianfeng.entity.User;

public class GoodsInfoBizImpl implements IGoodsInfoBiz {
	
	private IGoodsInfoDao giDao = new GoodsInfoDaoImpl();
 
	@Override
	public List<GoodInfo> queryAllGoodsInfo() {
		return giDao.queryAllGoodsInfo();
	}

	@Override
	public GoodInfo queryGoodInfoById(int goodId) {
		return giDao.queryGoodInfoById(goodId);
	}

	@Override
	public PageBean queryall(int currPage) {
		PageBean pb=new PageBean();
		int count=giDao.querycount();
		int pageSize=4;
		int rowIndex=(currPage-1)*pageSize;
		double ct=count;
		Double tp=Math.ceil(ct/pageSize);
		int totalPage=tp.intValue();
		List<GoodInfo> list=giDao.queryfenye(rowIndex,pageSize);
		pb.setTotalPage(totalPage);
		pb.setTotalCount(count);
		pb.setCurrPage(currPage);
		pb.setPageSize(pageSize);
		pb.setList(list);
		return pb;
	}

	@Override
	public int updateGoodInfo(GoodInfo goodInfo) {
		
		return giDao.updateGoodInfo(goodInfo);
	}

	@Override
	public int deleteById(int id) {
		
		return giDao.deleteByid(id);
	}

}
